{extend name="template/base" /}
{block name="content"}
<div class="page-container">
    <div class="cl pd-5 bg-1 bk-gray">
        <span class="l">
            店铺名称：<strong>{$store_info.name}</strong>
        </span>
    </div>
    <table class="table table-border table-bordered table-hover table-bg mt-20">
        <thead>
        <tr class="text-c">
            {include file="store/store/th_bind_class" /}
            <th width="70">操作</th>
        </tr>
        </thead>
        <tbody>
        {volist name="store_bind_class_list" id="vo"}
        <tr class="text-c">
            {include file="store/store/td_bind_class" /}
            <td class="f-14">
            	{tp:menu menu='sdeleteforever'}    
			</td>
        </tr>
        {/volist}
        </tbody>
  	  </table>
    
    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l">
            	添加经营类目
        </span>
    </div>
    <form class="form form-horizontal" id="form" method="post" action="{:url('store_bind_class_add')}">
            <input type="hidden" name="store_id" value="{$store_id}">
            <input id="goods_class" name="goods_class" type="hidden" value="">
            <div class="row cl">
                <label class="form-label col-xs-3 col-sm-3">选择分类：</label>
                <div class="formControls col-xs-6 col-sm-6" >
                    <span  class='' id="gcategory">
                        <select id="gcategory_class1" class=""  >
                            <option value="0">全部分类</option>
                            {if(!empty($goods_class) && is_array($goods_class) )}
                            {foreach ($goods_class as $gc)}
                            <option value="{$gc.id}" data-explain="{$gc.commis_rate}">{$gc.name}</option>
                            {/foreach}
                            {/if}
                        </select>
                    </span>
                </div>
                <div class="col-xs-3 col-sm-3"></div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-3 col-sm-3">分佣比例：</label>
                <div class="formControls col-xs-6 col-sm-6">
                    <input type="text"  id="commis_rate" name="commis_rate" style="width:200px" class="input-text" value="{$vo.mobile ?? ''}" placeholder="请填写分佣比例" >%
                </div>
                <div class="col-xs-3 col-sm-3"></div>
            </div>
            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <input class="btn btn-primary radius" type="submit" onclick="" value="添加">
                </div>
            </div>
        </form>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="/old/data/resource/js/jquery.validation.min.js" charset="utf-8"></script>
<script type="text/javascript" src="/old/data/resource/js/jquery.edit.js" charset="utf-8"></script>
<script type="text/javascript" src="/old/data/resource/js/common_select.js" charset="utf-8"></script>
<script type="text/javascript" src="__LIB__/Validform/5.3.2/Validform.min.js"></script>
<script type="text/javascript">
    var SITEURL = '{$Request.domain}';
$(document).ready(function(){
    gcategoryInit("gcategory");
    
    $(document).on('change','#gcategory select',function(){
        var cr = $(this).children(':selected').attr('data-explain');
        var category_id = '';
        $('#commis_rate').val(parseInt(cr) || '');
        $('#gcategory').find('select').each(function() {
            if(parseInt($(this).val(), 10) > 0) {
                category_id += $(this).val() + ',';
            } else {
                validation = false;
            }
        });
        $('#goods_class').val(category_id);
    });
    
    $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });
    
    $("#form").Validform({
            tiptype: 2,
            ajaxPost: true,
            showAllError: true,
            callback: function (ret) {
                ajax_progress(ret);
                location.reload();
            }
        });
        
    //选择规格做url跳转
    $('.select-spec').change(function(){
		if($(this).val() > 0 ){
			var store_id = $(this).attr('store_id');
			var sp_id = $(this).val();
			var class_id = $(this).attr('class_id');
			layer_open('编辑规格', '{$Think.config.base_url}{:url("admin/store.store/store_bind_class_spec_edit")}?sp_id='+sp_id+'&store_id='+store_id+'&class_id='+class_id);
		}
    });
});
</script>
{/block}